package com.showsu.editor.utils;

import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ReUtil;
import cn.hutool.http.HtmlUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


@Slf4j
public class StringUtil {

	/**
	 * 密码格式
	 */
	public static final String passwordReg = "^[0-9a-zA-Z_~!@#$%^&*]{6,16}$";

	private static final long one = 1l;
	private static final String oneStr = "+";

	private static final long ten = 10l;
	private static final String tenStr = "0+";

	private static final long oneHundred = 100l;
	private static final String oneHundredStr = "百+";

	private static final long oneThousand  = 1000l;
	private static final String oneThousandStr = "千+";

	private static final long tenThousand = 10000l;
	private static final String tenThousandStr = "万";
	private static final String tenThousandStr2 = "w";

	private static final long hundredThousand = 100000l;
	private static final String hundredThousandStr = "十万";

	private static final long oneMillion = 1000000l;
	private static final String millionStr = "百万";

	private static final long tenMillion = 10000000l;
	private static final String tenMillionStr = "千万";

	private static final long oneHundredMillion = 100000000l;
	private static final String oneHundredMillionStr = "亿";

	// 正则表达式匹配 http 或 https 链接
	private static final String regex = "(http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+)";
	/**
	 * 从文本中提取出一个http/https链接
	 * @param content
	 * @return
	 */
	public static String extractLinks(String content) {
		if (StringUtils.isBlank(content)) {
			return null;
		}
		// 定义正则表达式以匹配http/https链接
		//String regex = "(https?://\\S+)";
		Pattern pattern = Pattern.compile(regex);
		Matcher matcher = pattern.matcher(content);
		String decodeUrl=null;
		// 查找并打印所有匹配的链接
		while (matcher.find()) {
			decodeUrl= matcher.group();
		}
		if(StringUtils.isBlank(decodeUrl)){
			decodeUrl = StringUtil.extractLinks1(content);
			if(StringUtils.isBlank(decodeUrl)){
				decodeUrl = StringUtil.extractLinks2(content);
			}
			if(!decodeUrl.contains("://")){
				decodeUrl="https://"+decodeUrl;
			}
		}
		return decodeUrl;
	}

	private static final String regex1 = "https?://([\\w\\.-]+)\\.([a-zA-Z\\.]{2,6})([\\/\\w\\.-]*)*\\/?(\\?[\\w\\&\\=\\.\\-]*)?";

	public static String extractLinks1(String text){
		String formatStr= HtmlUtil.unescape(text);
		return ReUtil.getGroup0(regex1,formatStr);
	}

	private static final String regex2 = "(https?://)?(\\S+\\.\\S+)(/\\S*)?";

	/**
	 * 从文本中提取出一个链接
	 * @param content
	 * @return
	 */
	public static String extractLinks2(String content) {
		if (StringUtils.isBlank(content)) {
			return null;
		}
		// 定义正则表达式以匹配链接
		Pattern pattern = Pattern.compile(regex2);
		Matcher matcher = pattern.matcher(content);
		// 查找并打印所有匹配的链接
		while (matcher.find()) {
			return matcher.group();
		}
		return null;
	}
	
	/**
	 * 判断传入参数是否为空
	 * @param str
	 * @return
	 */
	public static boolean isEmpty(Object str){
		if (str == null || "".equals(str)) {
			return true;
		}
		return false;
	}
	public static String objToStr(Object obj){
		return (obj == null) ? "" : obj.toString();
	}
	
	/**
     * 利用正则表达式判断字符串是否是数字
     * @param str
     * @return
     */
    public static boolean isNumeric(String str){
           Pattern pattern = Pattern.compile("[0-9]*");
           Matcher isNum = pattern.matcher(str);
           if( !isNum.matches() ){
               return false;
           }
           return true;
    }
    
    /**
     * 利用正则表达式判断对象是否是数字
     * @param obj
     * @return
     */
    public static boolean isNumeric(Object obj){
    	if (isEmpty(obj)) {
			return false;
		}
    	return isNumeric(obj.toString());
	}
    
    /**
     * 利用正则表达式判断字符串是否是数字
     * 如果不是返回指定数字
     * @param obj
     * @return
     */
    public static Integer numericProcessing(Object obj,Integer resultInt){
    	if(isNumeric(obj)){
    		return Integer.valueOf(obj.toString());
    	}
    	return isNumeric(resultInt)?resultInt:0;
    }

	/**
	 * 删除特定字符
	 * @param str 原字符串
	 * @param deleteStr 删除字符
	 * @return
	 */
    public static String deleteChar(String str, String deleteStr) {
		StringBuffer stringBuffer = new StringBuffer(str);
		int iFlag;
		do {
			iFlag = stringBuffer.indexOf(deleteStr);
			if (iFlag != -1) {
				stringBuffer.deleteCharAt(iFlag);
			}
		} while (iFlag != -1);
		return stringBuffer.toString();
	}

	/**
	 * 获取随机字符串
	 * @param length 字符串长度
	 * @param type 类型：1-小写字母，2-大写字母，3-小写字母+数字，4-大写字母+数字，5-纯数字，6-小写字母+大写字母，其他-小写字母+大写字母+数字
	 * @return
	 */
	public static String randomStr(int length, int type) {
		Random random = new Random();
    	String str;
    	if (type == 1) {
    		str = "zxcvbnmlkjhgfdsaqwertyuiop";
		} else if (type == 2) {
    		str = "QWERTYUIOPASDFGHJKLZXCVBNM";
		} else if (type == 3) {
			str = "zxcvbnmlkjhgfdsaqwertyuiop1234567890";
		} else if (type == 4) {
			str = "QWERTYUIOPASDFGHJKLZXCVBNM1234567890";
		} else if (type == 5) {
			str = "1234567890";
		} else if (type == 6) {
			str = "zxcvbnmlkjhgfdsaqwertyuiopQWERTYUIOPASDFGHJKLZXCVBNM";
		} else {
			str = "zxcvbnmlkjhgfdsaqwertyuiopQWERTYUIOPASDFGHJKLZXCVBNM1234567890";
		}
    	int ranDomLength = str.length();
    	StringBuffer randomStr = new StringBuffer();
    	for (int i=0; i < length; i++) {
			int number = random.nextInt(ranDomLength);
			randomStr.append(str.charAt(number));
		}
    	return randomStr.toString();
	}

	/**
	 * 字符替换
	 * @param str 原字符串
	 * @param remainLength 剩下不被替换的长度
	 * @param replaceChar 替换字符
	 * @return
	 */
	private static String replace(String str, int remainLength, char replaceChar) {
		StringBuffer result = new StringBuffer();
		if (str.length() <= remainLength) {
			return str;
		}
		String replaceStr = str.substring(0, str.length() - remainLength);
		for (int i = 0; i < replaceStr.length(); i++){
			result.append(replaceChar);
		}
		result.append(str.substring(str.length()-remainLength));
		return result.toString();
	}

	/**
	 * 判断字符串中是否包含特殊字符
	 * @param str
	 * @return
	 */
	public static boolean isSpecialChar(String str) {
		String regEx = "[ _`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]|\n|\r|\t";
		Pattern p = Pattern.compile(regEx);
		Matcher m = p.matcher(str);
		return m.find();
	}

	/**
	 * 清除字符串中的特殊字符
	 * @param str
	 * @return
	 */
	public static String deleteSpecialChar(String str) {
		String regEx = "[ _`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~～！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]|\n|\r|\t";
		return str.replaceAll(regEx, "");
	}

	/**
	 * 清除字符串中的隐形字符
	 * 有时候会遇到一些非常特殊的字符，肉眼看不见，但是字符串中却是存在的，比如65039所指代的变量选择符
	 * @param str
	 * @return
	 */
	public static String deleteHideChar(String str) {
		StringBuilder result = new StringBuilder();
		for (int i = 0; i < str.length(); i++) {
			char c = str.charAt(i);
			int ss = (int) c;
			if (ss == 65039) {
				continue;
			}
			result.append(c);
		}
		return result.toString();
	}

	/**
	 * 获取一段字符串中所有#号和空格之间的内容，作为视频的话题
	 * @param str
	 * @return
	 */
	public static List<String> substringSpecial(String str) {
		List<String> result = new ArrayList<>();
		Pattern pattern = Pattern.compile("#\\s*(.*?)\\s* "); // 匹配#号和空格之间的内容
		Matcher matcher = pattern.matcher(str);
		while (matcher.find()) {
			String content = matcher.group(1); // 获取匹配到的内容
			//话题不应长于10个字符
			if (content.length() > 10) {
				continue;
			}
			result.add(content);
		}
		return result;
	}

	/**
	 * 密码格式校验
	 * @param pwd
	 * @return
	 */
	public static boolean isValidPassword(String pwd) {
		if (pwd == null) {
			return false;
		}
		Pattern pattern = Pattern.compile(passwordReg);
		Matcher matcher = pattern.matcher(pwd);
		boolean bool = matcher.matches();
		return bool;
	}

	/**
	 * 数字表达模糊转换，目前用在dy点赞数、收藏数、关注数、粉丝数等 的处理上
	 * 小于1w，原样返回
	 * 大于1w，返回*万，小数点后保留1位
	 * 大于1亿，返回*亿，小数点后保留1位
	 * @param num
	 * @return
	 */
	public static String changeNumber2FuzzyWriting(Long num) {
		if (num == null) {
			return Constant.zoreString;
		}
		if (num.compareTo(tenThousand) == -1) {
            return num.toString();
		}
		if (num.compareTo(oneHundredMillion) >= 0) {
			return NumberUtil.div(new BigDecimal(num), new BigDecimal(oneHundredMillion), 1).toString() + oneHundredMillionStr;
		}
		return NumberUtil.div(new BigDecimal(num), new BigDecimal(tenThousand), 1).toString() + tenThousandStr;
	}

	/**
	 * 数字表达模糊转换，目前用在dy 播放量 的处理上
	 * 个位数：具体值+随机3-5
	 * 十位数：X0
	 * 百位数：X00
	 * 千位数：X000
	 * 万位数：X.00万
	 * 十万位数：XX.00万
	 * 百万位数：XXX.00万
	 * 千万位数：XXXX.00万
	 * 亿位数：XXXXX.00万
	 * @param num
	 * @return
	 */
	public static String changeNumber2FuzzyWriting2(Long num) {
		if (num == null) {
			return Constant.analyzeHit7;
		}
		if (num.compareTo(ten) < 0) {
			return String.valueOf(num + Long.parseLong(String.valueOf(CodeGenerator.ranRan(3, 5))));
		}
		if (num.compareTo(oneHundred) < 0) {
			return num.toString().substring(0, num.toString().length() - 1) + Constant.zoreString;
		}
		if (num.compareTo(oneHundred) >= 0 && num.compareTo(oneThousand) < 0) {
			return num.toString().substring(0, num.toString().length() - 2) + Constant.zoreString + Constant.zoreString;
		}
		if (num.compareTo(oneThousand) >= 0 && num.compareTo(tenThousand) < 0) {
			return num.toString().substring(0, num.toString().length() - 3) + Constant.zoreString + Constant.zoreString + Constant.zoreString;
		}
		return NumberUtil.div(new BigDecimal(num), new BigDecimal(tenThousand), 0, RoundingMode.FLOOR).toString() + "." + Constant.zoreString + Constant.zoreString + tenThousandStr;
	}

	/**
	 * 数字表达模糊转换，目前用在dy 播放指数 的处理上
	 * 千位数及以下：具体值
	 * 千位数以上：X.X万
	 * @param num
	 * @return
	 */
	public static String changeNumber2FuzzyWriting3(Long num) {
		if (num == null) {
			return Constant.analyzeHit7;
		}
		if (num.compareTo(tenThousand) < 0) {
			return num.toString();
		}
		return NumberUtil.div(new BigDecimal(num), new BigDecimal(tenThousand), 1, RoundingMode.HALF_UP).toString() + tenThousandStr;
	}

	/**
	 * 数字表达模糊转换，目前用在 xhs预估阅读数 的处理上
	 * 千位数及以下：具体值
	 * 千位数以上：X.XX万
	 * @param num
	 * @return
	 */
	public static String changeNumber2FuzzyWriting4(Long num) {
		if (num == null) {
			return Constant.analyzeHit7;
		}
		if (num.compareTo(tenThousand) < 0) {
			return num.toString();
		}
		return NumberUtil.div(new BigDecimal(num), new BigDecimal(tenThousand), 2, RoundingMode.HALF_UP).toString() + tenThousandStr;
	}

	/**
	 * 数字表达模糊转换
	 * 千位数及以下：具体值
	 * 千位数以上：X.Xw
	 * @param num
	 * @return
	 */
	public static String changeNumber2FuzzyWriting5(Long num) {
		if (num == null) {
			return null;
		}
		if (num.compareTo(tenThousand) < 0) {
			return num.toString();
		}
		return NumberUtil.div(new BigDecimal(num), new BigDecimal(tenThousand), 1, RoundingMode.HALF_UP).toString() + tenThousandStr2;
	}

	/**
	 * 将模糊表达转换成数字
	 * 比如2.6万
	 * @param fuzzyWriting
	 * @return
	 */
	public static Integer changeFuzzyWriting2Number(String fuzzyWriting) {
		if (StringUtils.isBlank(fuzzyWriting)) {
			return null;
		}
		try {
			if (fuzzyWriting.contains(tenMillionStr)) {
				return NumberUtil.mul(new BigDecimal(Double.parseDouble(fuzzyWriting.replace(tenMillionStr, "").replace(oneStr, ""))), new BigDecimal(tenMillion)).intValue();
			}
			if (fuzzyWriting.contains(millionStr)) {
				return NumberUtil.mul(new BigDecimal(Double.parseDouble(fuzzyWriting.replace(millionStr, "").replace(oneStr, ""))), new BigDecimal(oneMillion)).intValue();
			}
			if (fuzzyWriting.contains(hundredThousandStr)) {
				return NumberUtil.mul(new BigDecimal(Double.parseDouble(fuzzyWriting.replace(hundredThousandStr, "").replace(oneStr, ""))), new BigDecimal(hundredThousand)).intValue();
			}
			if (fuzzyWriting.contains(tenThousandStr)) {
				return NumberUtil.mul(new BigDecimal(Double.parseDouble(fuzzyWriting.replace(tenThousandStr, "").replace(oneStr, ""))), new BigDecimal(tenThousand)).intValue();
			}
			if (fuzzyWriting.contains(oneThousandStr)) {
				return NumberUtil.mul(new BigDecimal(Double.parseDouble(fuzzyWriting.replace(oneThousandStr, ""))), new BigDecimal(oneThousand)).intValue();
			}
			if (fuzzyWriting.contains(oneHundredStr)) {
				return NumberUtil.mul(new BigDecimal(Double.parseDouble(fuzzyWriting.replace(oneHundredStr, ""))), new BigDecimal(oneHundred)).intValue();
			}
			if (fuzzyWriting.contains(tenStr)) {
				return NumberUtil.mul(new BigDecimal(Double.parseDouble(fuzzyWriting.replace(tenStr, ""))), new BigDecimal(ten)).intValue();
			}
			if (fuzzyWriting.contains(oneStr)) {
				return NumberUtil.mul(new BigDecimal(Double.parseDouble(fuzzyWriting.replace(oneStr, ""))), new BigDecimal(one)).intValue();
			}
			return Integer.parseInt(fuzzyWriting);
		} catch (Exception e) {
			log.error("StringUtil.changeFuzzyWriting2Number(String) error", e);
			return null;
		}
	}

	/**
	 * 从xhs粘贴的信息中，获取作品地址
	 * @param url
	 * @return
	 */
	public static String resolveXhsHttpUrl(String url) {
		String decodeUrl = null;
		if (StringUtils.isBlank(url)) {
			return decodeUrl;
		}
		try {
//			if (url.contains("复制本条信息")) {
//				int start = url.indexOf("http");
//				int end = url.lastIndexOf("，复制本条信息");
//				decodeUrl = url.substring(start, end);
//			} else if (url.contains("复制此链接")) {
//				int start = url.indexOf("http");
//				int end = url.lastIndexOf("复制此链接");
//				decodeUrl = url.substring(start, end);
//			} else if (url.contains("https://")) {
//				int start = url.indexOf("https://");
//				int end = url.lastIndexOf("\"");
//				//1.有一些链接是网页端的，比如浏览器里访问小红书的作品地址，从浏览器里拷贝出来的链接是没有最后的\的，例如：https://www.xiaohongshu.com/explore/641eff690000000011010cc1
//				//2.又或者链接的格式如：https://v.kuaishou.com/duOAeG 苹果实况动态壁纸，动态自取快手搜 “神图壁纸” 进小程序输7837取图 "景深壁纸 "iphone壁纸 "屏保该换了系列 "氛围感 该作品在快手被播放过70.7万次，点击链接，打开【快手极速版】直接观看！
//				if (end <= 0) {
//					int spaceEnd = url.substring(start).indexOf(" ");
//					if (spaceEnd > 0) {
//						end = start + spaceEnd;
//					} else {
//						end = url.length();
//					}
//				}
//				decodeUrl = url.substring(start, end);
//			} else if (url.contains("http://")) {
//				int start = url.indexOf("http://");
//				int end = url.lastIndexOf("\"");
//				//1.有一些链接是网页端的，比如浏览器里访问小红书的作品地址，从浏览器里拷贝出来的链接是没有最后的\的，例如：http://xhslink.com/ozkjXp
//				//2.又或者链接的格式如：http://v.kuaishou.com/duOAeG 苹果实况动态壁纸，动态自取快手搜 “神图壁纸” 进小程序输7837取图 "景深壁纸 "iphone壁纸 "屏保该换了系列 "氛围感 该作品在快手被播放过70.7万次，点击链接，打开【快手极速版】直接观看！
//				if (end <= 0) {
//					int spaceEnd = url.substring(start).indexOf(" ");
//					if (spaceEnd > 0) {
//						end = start + spaceEnd;
//					} else {
//						end = url.length();
//					}
//				}
//				decodeUrl = url.substring(start, end);
//			}
			decodeUrl = StringUtil.extractLinks(url);
		} catch (Exception ex) {
			log.error("StringUtil.resolveXhsHttpUrl(String) error-url:{},exception:{}", url, ex);
		}
		return decodeUrl;
	}

	/**
	 * 从dy粘贴的信息中，获取作品地址
	 * @param url
	 * @return
	 */
	public static String resolveDyHttpUrl(String url) {
		//int start = url.indexOf("http");
		//int end = url.lastIndexOf("/");
		//String decodeUrl = url.substring(start, end);
		//return decodeUrl;
		List<String> resultList = getUrlFromString(url);
		if (resultList.size() == 0) {
			return null;
		}
		return resultList.get(0);
	}

	/**
	 * 同时支持解析xhs、dy的作品地址
	 * @param url
	 * @return
	 */
	public static String resolveHttpUrl(String url) {
		if (url.indexOf("xhslink.com") > -1) {
			return resolveXhsHttpUrl(url);
		}
		return resolveDyHttpUrl(url);
	}

	/**
	 * 通过正则从文本中获取到http/https请求链接
	 * @param str
	 * @return
	 */
	public static List<String> getUrlFromString(String str) {
		// 定义URL匹配的正则表达式模式
		String urlPattern = "(?i)\\b((?:https?://|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?«»“”‘’]))";
		Pattern pattern = Pattern.compile(urlPattern);
		Matcher matcher = pattern.matcher(str);

		List<String> result = new ArrayList<>();
		// 遍历匹配结果并输出
		while (matcher.find()) {
			result.add(matcher.group());
		}
		return result;
	}

	/**
	 * 处理内容截取用户编号
	 * @param url
	 * @param startStr
	 * @param endStr
	 * @return
	 */
	public static String subStringFromHttpUrl(String url, String startStr, String endStr) {
		int start = url.indexOf(startStr);
		int end = url.lastIndexOf(endStr);
		end = end== -1 ? url.length() : end;
		String decodeUrl = url.substring(start, end);
		return decodeUrl;
	}

	/**
	 * 处理内容截取用户编号
	 * @param url
	 * @param startStr
	 * @param endStr
	 * @return
	 */
	public static String subStringFromHttpUrlV2(String url, String startStr, String endStr) {
		//用lastIndexOf而非indexOf是因为碰到一些用户黏贴链接前没删干净，导致内容里有重复的，那么我们只截取最后的内容即可
		int start = url.lastIndexOf(startStr);
		if(start == -1){
			return null;
		}
		int end = url.lastIndexOf(endStr);
		end = end== -1 ? url.length() : end;
		String decodeUrl = url.substring(start, end);
		return decodeUrl;
	}

	/**
	 * 增加数字的千分位、百万分位、十亿分位
	 * @param num
	 * @return
	 */
	public static String numberSeparator(Long num) {
		if (num == null) {
			return "";
		}
		String numStr = num.toString();
		if (num < 1000L) {
			return numStr;
		}
		if (num >= 1000L && num < 1000000L) {
			return numStr.substring(0, numStr.length() - 3) + "," + numStr.substring(numStr.length() - 3);
		}
		if (num >= 1000000L && num < 1000000000L) {
			return numStr.substring(0, numStr.length() - 6)
					+ "," + numStr.substring(numStr.length() - 6, numStr.length() - 3)
					+ "," + numStr.substring(numStr.length() - 3);
		}
		return numStr.substring(0, numStr.length() - 9)
				+ "," + numStr.substring(numStr.length() - 9, numStr.length() - 6)
				+ "," + numStr.substring(numStr.length() - 6, numStr.length() - 3)
				+ "," + numStr.substring(numStr.length() - 3);
	}

	/**
	 * 增加数字的千分位、百万分位、十亿分位
	 * @param num
	 * @return
	 */
	public static String numberSeparator(Integer num) {
		if (num == null) {
			return "";
		}
		String numStr = num.toString();
		if (num < 1000L) {
			return numStr;
		}
		if (num >= 1000L && num < 1000000L) {
			return numStr.substring(0, numStr.length() - 3) + "," + numStr.substring(numStr.length() - 3);
		}
		if (num >= 1000000L && num < 1000000000L) {
			return numStr.substring(0, numStr.length() - 6)
					+ "," + numStr.substring(numStr.length() - 6, numStr.length() - 3)
					+ "," + numStr.substring(numStr.length() - 3);
		}
		return numStr.substring(0, numStr.length() - 9)
				+ "," + numStr.substring(numStr.length() - 9, numStr.length() - 6)
				+ "," + numStr.substring(numStr.length() - 6, numStr.length() - 3)
				+ "," + numStr.substring(numStr.length() - 3);
	}

	/**
	 * unicode转中文
	 * @param unicodeString
	 * @return
	 */
	public static String convertUnicodeToChinese(String unicodeString) {
		if (StringUtils.isBlank(unicodeString)) {
			return "";
		}
		try {
			Pattern pattern = Pattern.compile("\\\\u([0-9a-fA-F]{4})");
			Matcher matcher = pattern.matcher(unicodeString);
			StringBuffer result = new StringBuffer();
			while (matcher.find()) {
				String unicode = matcher.group(1);
				//同样也是通过Integer.parseInt(String str,radix.)方式把十六进制转化成十进制
				int codePoint = Integer.parseInt(unicode, 16);
				//转换成中文
				String chinese = new String(new char[]{(char) codePoint});
				//Unicode替换中文
				matcher.appendReplacement(result, Matcher.quoteReplacement(chinese));
			}
			matcher.appendTail(result);
			return result.toString();
		} catch (Exception e) {
			log.error("StringUtil.convertUnicodeToChinese(String) error", e);
			return "";
		}
	}

	/**
	 * 包含emoji表情的字符串实际长度
	 *
	 * @param str 原有str
	 * @return str实际长度
	 */
	public static int realStringLength(String str) {
		int count = 0;
		for (int i = 0; i < str.length(); i++) {
			char c = str.charAt(i);
			if (Character.isHighSurrogate(c) || Character.isLowSurrogate(c)) {
				i++;
			}
			count++;
		}

		return count;
	}

	public static String replaceReifString(String str) {
		if (StringUtils.isBlank(str)) {
			return null;
		}
		return str.replace("/format/heif","/format/jpg")
				.replace("/format/heic","/format/jpg")
				.replace("/format/reif","/format/jpg")
				.replace("/format/webp","/format/jpg");
	}

	public static void main(String[] args) {
		//List<String> test = substringSpecial("#舞蹈 #艺考 #舞蹈课堂随拍 #中国舞卿老师  你的同学有这样帮你撕腿吗@抖音小助手 @DOU+小助手");
		//System.out.println(deleteSpecialChar(" 哈 哈$yuyiy&*(*()*&dsafdf"));
		//List<String> testList = getUrlFromString("5.15  https://www.iesdouyin.com/iRryKw4k/ 复制打开抖音，看看# 电视剧问心 # 问心求你别拿林逸开刀 注定小心翼翼的一生，也祝你长命百岁# 电视剧问心# 问心求... 07/31 SyT:/ L@j.pQ");
		//System.out.println(testList.get(0));
//		System.out.println(changeNumber2FuzzyWriting2(815600L));
//		BigDecimal a=new BigDecimal(123123);
//		BigDecimal b=new BigDecimal(456456L);
//
//		BigDecimal number = a.divide(b,2,BigDecimal.ROUND_HALF_UP);
//		System.out.println(number.toString());

		System.out.println(changeFuzzyWriting2Number("1+"));

	}

}
